(function($){
  $(document).ready(function(){
    ZeroClipboard.config({
      moviePath: Drupal.settings.myacc.moviePath
    });
    var client = new ZeroClipboard( $('.myacc-copy') );
    client.on( 'load', function(client) {
      // alert( "movie is loaded" );
      client.on( 'datarequested', function(client) {
        client.setText(this.innerHTML);
      } );
      client.on('complete', function(client, args) {
        var scrollTop = $(window).scrollTop();
        var offset = $(this).offset();
        var top = scrollTop != 0 ? (offset.top - scrollTop) : offset.top;
        var msg = "Copied text to clipboard";
        var element = $('<div class="myacc-message">' + msg + '</div>')
        element.css('left', offset.left + 50);
        element.css('top', top);
        $('body').append(element);
        $(element).delay(600).fadeOut(300, function(){
          this.remove();
        });
      });
    } );
    client.on( 'wrongflash noflash', function() {
      ZeroClipboard.destroy();
    });
  });
})(jQuery);